package org.example.jwt;

import io.jsonwebtoken.Claims;

/**
 * {@code @BelongsProject:}xkLab
 * {@code @BelongsPackage:}org.example.jwt
 * {@code @Author:} Xukai
 * {@code @CreateTime:}2025-03-25  07:16
 * {@code @Description:Jwt测试逻辑}
 * {@code @Version:}1.0
 */
public class TestJwt {
    public static void main(String[]args){
        //想试试生成自己的token,只需修改username
        String username = "testJwt";

        String token = Jwt.generateToken(username);
        System.out.println("username:" + username);
        System.out.println("生成token:" + token);

        Claims claims = Jwt.validateToken(token);
        System.out.println("解析token:");
        System.out.println("claims" + claims);// 打印claims(以键值对形式存在)
        System.out.println("subject:" + claims.getSubject());
        System.out.println("签发时间:" + claims.getIssuedAt());
        System.out.println("过期时间:" + claims.getExpiration());
    }
}
